package com.ruoyi.service.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.service.domain.ServiceSuppliesname;
import com.ruoyi.service.service.IServiceSuppliesnameService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 耗材与别名Controller
 * 
 * @author ZDL
 * @date 2024-10-21
 */
@RestController
@RequestMapping("/service/suppliesname")
public class ServiceSuppliesnameController extends BaseController
{
    @Autowired
    private IServiceSuppliesnameService serviceSuppliesnameService;

    /**
     * 查询耗材与别名列表
     */
    @PreAuthorize("@ss.hasPermi('service:suppliesname:list')")
    @GetMapping("/list")
    public TableDataInfo list(ServiceSuppliesname serviceSuppliesname)
    {
        startPage();
        List<ServiceSuppliesname> list = serviceSuppliesnameService.selectServiceSuppliesnameList(serviceSuppliesname);
        return getDataTable(list);
    }

    /**
     * 导出耗材与别名列表
     */
    @PreAuthorize("@ss.hasPermi('service:suppliesname:export')")
    @Log(title = "耗材与别名", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ServiceSuppliesname serviceSuppliesname)
    {
        List<ServiceSuppliesname> list = serviceSuppliesnameService.selectServiceSuppliesnameList(serviceSuppliesname);
        ExcelUtil<ServiceSuppliesname> util = new ExcelUtil<ServiceSuppliesname>(ServiceSuppliesname.class);
        util.exportExcel(response, list, "耗材与别名数据");
    }

    /**
     * 获取耗材与别名详细信息
     */
    @PreAuthorize("@ss.hasPermi('service:suppliesname:query')")
    @GetMapping(value = "/{suppliesnameId}")
    public AjaxResult getInfo(@PathVariable("suppliesnameId") Long suppliesnameId)
    {
        return success(serviceSuppliesnameService.selectServiceSuppliesnameBySuppliesnameId(suppliesnameId));
    }

    /**
     * 新增耗材与别名
     */
    @PreAuthorize("@ss.hasPermi('service:suppliesname:add')")
    @Log(title = "耗材与别名", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ServiceSuppliesname serviceSuppliesname)
    {
        return toAjax(serviceSuppliesnameService.insertServiceSuppliesname(serviceSuppliesname));
    }

    /**
     * 修改耗材与别名
     */
    @PreAuthorize("@ss.hasPermi('service:suppliesname:edit')")
    @Log(title = "耗材与别名", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ServiceSuppliesname serviceSuppliesname)
    {
        return toAjax(serviceSuppliesnameService.updateServiceSuppliesname(serviceSuppliesname));
    }

    /**
     * 删除耗材与别名
     */
    @PreAuthorize("@ss.hasPermi('service:suppliesname:remove')")
    @Log(title = "耗材与别名", businessType = BusinessType.DELETE)
	@DeleteMapping("/{suppliesnameIds}")
    public AjaxResult remove(@PathVariable Long[] suppliesnameIds)
    {
        return toAjax(serviceSuppliesnameService.deleteServiceSuppliesnameBySuppliesnameIds(suppliesnameIds));
    }
}
